package com.blue.http.config;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/**
 * SSLConfig解析
 *
 * @author zhengjin
 * @since 1.0 2018年10月26日
 */
public class SSLConfigParser extends AbstractSimpleBeanDefinitionParser
{
	public SSLConfigParser()
	{
	}

	@Override
	protected Class<?> getBeanClass(Element element)
	{
		return SSLConfig.class;
	}

	@Override
	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
	{
		try
		{
			builder.addPropertyValue("ssl", element.getAttribute("ssl"));
			builder.addPropertyValue("jks", element.getAttribute("jks"));
			builder.addPropertyValue("pwd", element.getAttribute("pwd"));
			builder.addPropertyValue("alias", element.getAttribute("alias"));
		}
		catch (Exception e)
		{
			parserContext.getReaderContext().error(SSLConfig.class.getName() + " 无法创建", element, null, e);
		}
	}
}
